home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / examples / chap04 / LightOnOff.java < prev    next >
Text File  |  1996-09-12  |  649b  |  31 lines

  1. //
  2. // toggle the light state.
  3. //
  4.  
  5. import vrml.*;
  6. import vrml.node.*;
  7. import vrml.field.*;
  8.  
  9. public class LightOnOff extends Script{
  10.     SFBool turnOnLight;
  11.     // light state.
  12.     boolean onOff = false;
  13.  
  14.     public void initialize(){
  15.         // get the reference of the event out 'turnOnLight'.
  16.         turnOnLight = (SFBool)getEventOut("turnOnLight");
  17.     }
  18.  
  19.     public void processEvent(Event e){
  20.         if(e.getName().equals("touchTime") == true){
  21.         
  22.             // toggle the light state.
  23.             onOff = !onOff;
  24.  
  25.             // send the event.
  26.             turnOnLight.setValue(onOff);
  27.         }
  28.     }
  29. }
  30.  
  31.